<template>
	<!-- 意见反馈 -->
	<view id="app-wrapper">
		<view class="wrap-header">
			反馈内容
		</view>
		<view class="wrap-main">
			<u-input maxlength="300" :border="true" :auto-height="false" height="200" placeholder="请简要描述您的问题和意见(不少于30字)，以便我们提供更好的帮助"
			 type="textarea" v-model="value" />
		</view>
		<view class="wrap-header">
			图片上传
		</view>
		<view class="wrap-main">
			<u-upload max-count="6" ref="uUpload" :action="action" :auto-upload="false"></u-upload>
		</view>
		<view class="warp-footer">
			<view @click="submitFn" :class="{'submit-btn':true,'submit-color':value.length > 30}">提交</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				value: '',
				action: 'http://www.example.com/upload'
			};
		},
		methods: {
			api(data) {
			return	new Promise((res,err)=>{
					uni.request({
						url: 'http://jianadmin.wenhualieducation.com:8899' + data.url, //地址
						method: data.method, //方式-必须大写
						data: data.option,
						dataType: data.type || 'application/json', //请求格式
						header: {
						 token: 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJhdWQiOiJ3ZWIiLCJpc3MiOiJzcHJpbmctYm9vdC1wbHVzIiwiZXhwIjoxNjA0OTQ4MjkzLCJpYXQiOjE2MDQ5MTIyOTMsImp0aSI6IjUxMTM1Y2M1YTZkNzRiODg4ZjU1ODFkYWM2ZThhYWYyIiwidXNlcm5hbWUiOiIxMzI1NzI0MjA2Nzg4MzQxNzYxIn0.lEubb8Dt3licBjIC858nMxdk6kMOslUJk4Stl6XwKZU'
						},
						success: data => {
							 res(data)
						},
						fail: data => {
							 err(data)
						}
					})
				})
			},
			submitFn() {
				let option = {
					url: '/api/bmOpinion/getSaveOpinion',
					method: 'POST',
					option: {
						bmOpinionQueryVo: {
							userId: "1325724206788341761",
							opinion: this.value,
							imageOne: "",
							imageTwo: ""
						}
					}
				}
				this.api(option).then(res => {
					console.log(res, "正确")
				}).catch(err => {
					console.log(err, "错误")
				})
			}

		}
	}
</script>

<style scoped lang="scss">
	#app-wrapper {
		padding: 40rpx 20rpx;

		.wrap-header {
			font-size: 38rpx;
			font-weight: 700;
		}

		.wrap-main {
			padding: 30rpx 0;
		}

		.warp-footer {
			position: fixed;
			bottom: 30rpx;
			left: 0;
			width: 100%;

			.submit-btn {
				width: 80%;
				height: 70rpx;
				line-height: 70rpx;
				margin: 0 auto;
				color: #fff;
				text-align: center;
				background-color: #eeeded;
				border-radius: 10rpx;
				font-weight: 600;
			}

			.submit-color {
				background-color: #0099ff;
			}
		}
	}
</style>
